import request from '@/utils/request'
const UpmsDataSourceService = {
  state: {},

  mutations: {},

  actions: {
    /**
     * 三方数据库分页
     */
    upmsDataSourcePage({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.get('dataSource/page', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    /**
    * 根据主键获得三方数据库
    */
    upmsDataSourceGetById({ commit }, id) {
      return new Promise((resolve, reject) => {
        request.get('dataSource/getById/' + id).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    /**
    * 根据主键获得三方数据库详情
    */
    upmsDataSourceGetDetailsById({ commit }, id) {
      return new Promise((resolve, reject) => {
        request.get('dataSource/getDetailsById/' + id).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },

    /**
     * 三方数据库保存
     */
    upmsDataSourceSave({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('dataSource/save', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    /**
     * 三方数据库更新
     */
    upmsDataSourceUpdate({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('dataSource/update/' + params.id, params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    /**
     * 三方数据库删除
     */
    upmsDataSourceRemove({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('dataSource/remove', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    upmsDataSourceTestConnect({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('dataSource/testConnect', params).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default UpmsDataSourceService
